const util = require('../../utils/util.js');
const api = require('../../config/api.js');
const user = require('../../services/user.js');
//获取应用实例
const app = getApp()

Page({
    data: {

    },
    onLoad: function (options) {

    },
    onShow: function () {
        let userInfo = wx.getStorageSync('userInfo');
        if (userInfo != '') {
            wx.navigateBack();
        };
    },
    getUserInfo: function (e) {
        let userInfo = e.detail.userInfo;
        user.WeixinByLogin().then(res => {
            console.log(res)
            app.globalData.userInfo = userInfo;
            wx.setStorage({
                key:"userInfo",
                data:e.detail.userInfo
            })
            if (res.content.isNew) {
                wx.setStorageSync('isReceive',0)
                wx.navigateTo({
                    url: '/pages/active-receive/index',
                });
            } else {
                wx.navigateBack();
            }

        }).catch((err) => {});
    },
    goBack: function () {
        wx.navigateBack();
    }
})